<template>
  <div class="stats-cards">
    <div class="stat-card primary">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.totalContainers) }}</div>
        <div class="stat-label">器具总数</div>
        <div class="stat-trend">
          <i class="el-icon-arrow-up"></i>
          <span>周同比 {{ statsData.totalGrowth }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-box"></i>
      </div>
    </div>

    <div class="stat-card success">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.inStockContainers) }}</div>
        <div class="stat-label">在库器具</div>
        <div class="stat-trend">
          <i class="el-icon-arrow-up"></i>
          <span>日同比 {{ statsData.inStockGrowth }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-house"></i>
      </div>
    </div>

    <div class="stat-card warning">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.inTransitContainers) }}</div>
        <div class="stat-label">在途器具</div>
        <div class="stat-trend">
          <i class="el-icon-arrow-down"></i>
          <span>转化率 {{ statsData.transitRate }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-truck"></i>
      </div>
    </div>

    <div class="stat-card danger">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.sealedContainers) }}</div>
        <div class="stat-label">封存器具</div>
        <div class="stat-trend">
          <i class="el-icon-minus"></i>
          <span>运营活跃度 {{ statsData.activityRate }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-lock"></i>
      </div>
    </div>

    <div class="stat-card info">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.abnormalContainers) }}</div>
        <div class="stat-label">异常器具</div>
        <div class="stat-trend">
          <i class="el-icon-warning"></i>
          <span>周同比 {{ statsData.abnormalGrowth }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-warning-outline"></i>
      </div>
    </div>

    <div class="stat-card purple">
      <div class="stat-card-content">
        <div class="stat-number">{{ formatNumber(statsData.newContainers) }}</div>
        <div class="stat-label">新增器具</div>
        <div class="stat-trend">
          <i class="el-icon-plus"></i>
          <span>日同比 {{ statsData.newGrowth }}%</span>
        </div>
      </div>
      <div class="stat-icon">
        <i class="el-icon-circle-plus"></i>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'StatsCards',
  props: {
    statsData: {
      type: Object,
      default: () => ({
        totalContainers: 126560,
        totalGrowth: 12,
        inStockContainers: 8846,
        inStockGrowth: 11,
        inTransitContainers: 6560,
        transitRate: 60,
        sealedContainers: 1200,
        activityRate: 78,
        abnormalContainers: 45,
        abnormalGrowth: -5,
        newContainers: 890,
        newGrowth: 15
      })
    }
  },
  methods: {
    formatNumber(num) {
      if (num >= 10000) {
        return (num / 10000).toFixed(1) + '万'
      }
      return num.toLocaleString()
    }
  }
}
</script>

<style lang="scss" scoped>
.stats-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
  }
  
  &.primary::before { background: #409eff; }
  &.success::before { background: #67c23a; }
  &.warning::before { background: #e6a23c; }
  &.danger::before { background: #f56c6c; }
  &.info::before { background: #909399; }
  &.purple::before { background: #9c27b0; }
  
  .stat-card-content {
    flex: 1;
    
    .stat-number {
      font-size: 28px;
      font-weight: bold;
      color: #303133;
      margin-bottom: 4px;
    }
    
    .stat-label {
      font-size: 14px;
      color: #606266;
      margin-bottom: 8px;
    }
    
    .stat-trend {
      font-size: 12px;
      color: #67c23a;
      
      i {
        margin-right: 2px;
      }
    }
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(64, 158, 255, 0.1);
    
    i {
      font-size: 24px;
      color: #409eff;
    }
  }
  
  &.success .stat-icon {
    background: rgba(103, 194, 58, 0.1);
    i { color: #67c23a; }
  }
  
  &.warning .stat-icon {
    background: rgba(230, 162, 60, 0.1);
    i { color: #e6a23c; }
  }
  
  &.danger .stat-icon {
    background: rgba(245, 108, 108, 0.1);
    i { color: #f56c6c; }
  }
  
  &.info .stat-icon {
    background: rgba(144, 147, 153, 0.1);
    i { color: #909399; }
  }
  
  &.purple .stat-icon {
    background: rgba(156, 39, 176, 0.1);
    i { color: #9c27b0; }
  }
}
</style>
